package com.leetcode.August;

import javax.swing.tree.TreeNode;

/**
 * @Description: 101. 对称二叉树
 * @Author: Mr.Fxy
 * @CreateTime: 2024-08-30 16:09
 */
public class LC101对称二叉树 {
    public boolean isSymmetric(TreeNode root) {
        return dfs(root.left,root.right);
    }
    private boolean dfs(TreeNode p, TreeNode q) {
        if (p==null&&q==null) return p==q;
        return p.val==q.val && dfs(p.left,q.right) && dfs(p.right,q.left);
    }
}
